import 'package:fish_redux/fish_redux.dart';

enum SubjectListAction {
  onLoad,
  loaded,
  loading,
  listResult,
  onReload,
  onDelete,
  deleted,
  onCreate,
}

class SubjectListActionCreator {
  static Action onLoad() {
    return Action(SubjectListAction.onLoad);
  }

  static Action loading(bool self) {
    return Action(SubjectListAction.loading, payload: {'self': self});
  }

  static Action loaded(bool self) {
    return Action(SubjectListAction.loaded, payload: {'self': self});
  }

  static Action listResult(
      bool self, List items, var pageTotal, var pageIndex) {
    return Action(SubjectListAction.listResult, payload: {
      'self': self,
      'items': items,
      "pageTotal": pageTotal,
      "pageIndex": pageIndex
    });
  }

  static Action onReload(callback) {
    return Action(SubjectListAction.onReload, payload: callback);
  }

  static Action onDelete(int index) {
    return Action(SubjectListAction.onDelete, payload: index);
  }

  static Action deleted(bool self, int index) {
    return Action(SubjectListAction.deleted,
        payload: {'self': self, 'index': index});
  }

  static Action onCreate() {
    return Action(SubjectListAction.onCreate);
  }
}
